package android.medicalcloud.com.yiapp.yilian.logic;

import android.medicalcloud.com.yiapp.base.cach.PreferceManager;
import android.medicalcloud.com.yiapp.base.net.lisener.ViewNetCallBack;
import android.medicalcloud.com.yiapp.base.utils.Logger;
import android.medicalcloud.com.yiapp.base.utils.MapBuilder;
import android.medicalcloud.com.yiapp.yilian.configer.enums.HttpConfig;
import android.medicalcloud.com.yiapp.yilian.model.BannersModel;
import android.medicalcloud.com.yiapp.yilian.model.BaseModeal;
import android.medicalcloud.com.yiapp.yilian.model.ConfigModel;
import android.medicalcloud.com.yiapp.yilian.utils.android.GsonTool;
import android.medicalcloud.com.yiapp.yilian.utils.android.JsonTool;
import android.medicalcloud.com.yiapp.yilian.utils.net.ConnectTool;

import java.io.Serializable;

/**
 * Created by wanggenlin on 17-5-18.
 */
public class PushController {
    static PushController instance;

    public static PushController getInstance() {
        if (instance == null) {
            instance = new PushController();
        }
        return instance;
    }
    /**
     * login
     */
    public void bind() {
        try {
            ConnectTool.httpRequest(
                    HttpConfig.bindPush,
                    new MapBuilder<String, Object>()
                            .add("pushId",PreferceManager.getInsance().getValueBYkey("gtId"))
                            .getMap()
                    , new CommonRespone()
                    , BaseModeal.class);
        } catch (Exception e) {
            Logger.e(e.getLocalizedMessage(), e);
        }
    }

    /**
     * login
     */
    public void unbind() {
        try {
            ConnectTool.httpRequest(
                    HttpConfig.ubBindPush,
                    new MapBuilder<String, Object>().add("pushId",PreferceManager.getInsance().getValueBYkey("gtId"))
                            .getMap()
                    , new CommonRespone()
                    , BaseModeal.class);
        } catch (Exception e) {
            Logger.e(e.getLocalizedMessage(), e);
        }
    }

    /**
     * login
     */
    public void unbind(ViewNetCallBack callBack) {
        try {
            ConnectTool.httpRequest(
                    HttpConfig.ubBindPush,
                    new MapBuilder<String, Object>().add("pushId",PreferceManager.getInsance().getValueBYkey("gtId"))
                            .getMap()
                    , callBack
                    , BaseModeal.class);
        } catch (Exception e) {
            Logger.e(e.getLocalizedMessage(), e);
        }
    }

    private  class CommonRespone implements  ViewNetCallBack{
        @Override
        public void onConnectStart(Object o) {

        }

        @Override
        public void onConnectEnd() {

        }

        @Override
        public void onFail(Exception e, Object o, String reslut) {

        }

        @Override
        public void onData(Serializable result, int flag, boolean fromNet, Object o) {
        Logger.e(o.toString()+"       fda");
        }
    }



}
